<template>
  <view class="my-info-container">

    <view class="content-area">
      <view class="info-section">
        <view class="info-item">
          <text class="info-label">{{ userInfo.nick_name }}</text>
        </view>
        <view class="info-item">
          <view class="info-row">
            <text class="info-text">性别：</text>
            <text class="info-value">{{ userInfo.gender }}</text>
          </view>
          <view class="info-row">
            <text class="info-text">民族：</text>
            <text class="info-value">{{ userInfo.nation || "-" }}</text>
          </view>
        </view>
        <view class="info-item">
          <text class="info-text">出生日期：</text>
          <text class="info-value">{{ userInfo.birthdate }}</text>
        </view>
        <view class="info-item">
          <text class="info-text">身份证号：</text>
          <text class="info-value">{{ userInfo.id_card }}</text>
        </view>
        <view class="info-item">
          <text class="info-text">本人联系电话：</text>
          <text class="info-value">{{ userInfo.mobile }}</text>
        </view>
        <view class="info-item">
          <text class="info-text">紧急联系人姓名：</text>
          <text class="info-value">{{ userInfo.emergency_contact_name }}</text>
        </view>
        <view class="info-item">
          <text class="info-text">紧急联系人电话：</text>
          <text class="info-value">{{ userInfo.emergency_contact_mobile }}</text>
        </view>
        <view class="info-item">
          <text class="info-text">上次于本医院：</text>
          <text class="info-value">未填写</text>
        </view>
        <view class="info-item">
          <text class="info-text">正在诊疗单位：</text>
          <text class="info-value">深圳市人民医院</text>
        </view>
        <view class="info-item">
          <text class="info-text">咨询医生姓名：</text>
          <text class="info-value">桥小杏</text>
        </view>
      </view>
      <view class="edit-button">
        <view class="primary-btn" @click="goToEdit">
          <text class="btn-text">编辑</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { info } from '@/api/user';
export default {
  data() {
    return {
      statusBarHeight: 0,
      userInfo: {},
    };
  },
  onLoad() {
    this.getSystemInfo();
  },
  async onShow() {
    try {
      const _res = await info();
      this.userInfo = _res?.data?.userInfo;
      console.log('个人信息', _res);
    } catch (err) {
      console.log('报错了哈', err);
    }
  },
  methods: {
    getSystemInfo() {
      const systemInfo = uni.getSystemInfoSync();
      this.statusBarHeight = systemInfo.statusBarHeight || 0;
    },
    goBack() {
      uni.navigateBack();
    },
    goToEdit() {
      uni.navigateTo({
        url: '/pages/myInfo/edit',
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.my-info-container {
  min-height: 100vh;
  background: #f5f5f5;
}

.status-bar {
  background: #ffffff;
}

.info-navbar {
  background: #ffffff;
  height: 88rpx;
  border-bottom: 1px solid #e5e5e5;
}

.info-navbar .navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 32rpx;
}

.nav-left {
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-icon {
  font-size: 48rpx;
  color: #333333;
  font-weight: bold;
}

.nav-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #333333;
}

.nav-right {
  display: flex;
  align-items: center;
}

.nav-action-btn {
  width: 60rpx;
  height: 60rpx;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 16rpx;
}

.action-dots,
.action-location {
  font-size: 24rpx;
  color: #666666;
}

.content-area {
  padding: 32rpx;
}

.info-section {
  background: #ffffff;
  border-radius: 16rpx;
  padding: 32rpx;
  margin-bottom: 40rpx;
}

.info-item {
  margin-bottom: 32rpx;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 40rpx;
  font-weight: bold;
  color: #333333;
}

.info-row {
  display: flex;
  align-items: center;
  margin-bottom: 16rpx;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-text {
  font-size: 32rpx;
  color: #333333;
  margin-right: 16rpx;
  min-width: 200rpx;
}

.info-value {
  font-size: 32rpx;
  color: #666666;
  flex: 1;
}

.edit-button .primary-btn {
  width: 100%;
  height: 96rpx;
  background: #4ecdc4;
  border-radius: 48rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-text {
  font-size: 32rpx;
  color: #ffffff;
  font-weight: 500;
}
</style>
